package com.ticket.sass.common.douyin.openapi.resposne

import com.google.gson.annotations.SerializedName

/**
 * error_code 和 VerifyResult.result 均为 0 代表验券成功
 */
data class VerifyCouponData(
    // 验券结果
    @SerializedName("verify_results") val verifyResults: List<VerifyResult>,
) : ApiResponseBaseData() {
    data class VerifyResult(
        @SerializedName("order_id") val orderId: String,
        @SerializedName("origin_code") val originCode: String,
        // 验券结果码，0表示成功，非0表示失败
        @SerializedName("result") val result: Int,
        @SerializedName("verify_id") val verifyId: String,
        @SerializedName("account_id") val accountId: String,
        @SerializedName("certificate_id") val certificateId: String,
        @SerializedName("code") val code: String,
        @SerializedName("msg") val msg: String
    )
    fun isVerifySuccess(): Boolean {
        return errorCode == 0 && verifyResults.all { it.result == 0 }
    }
}
